package framework.editor;


import framework.data.Usuario;
import framework.panes.Editor;
import framework.panes.Editor;
import framework.panes.EditorPane;
import framework.panes.EditorPane;
import java.awt.Frame;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * UsuarioPane.java
 *
 * Created on May 5, 2011, 3:09:59 PM
 */
/**
 *
 * @author usuario
 */
public class UsuarioEditor extends EditorPane
{
    private Usuario usuario;
    
    /**
     * 
     * @param Parent
     * @param produto
     * @return 
     */
    public static boolean edit( Frame parent, Usuario usuario )
    {
        UsuarioEditor pane = new UsuarioEditor();
        
        pane.setUsuario( usuario );
        
        return Editor.edit( parent, pane, "Cadastro de usuarios" );
    }

    /** Creates new form UsuarioPane */
    public UsuarioEditor()
    {
        initComponents ();
    }
    
    public void setUsuario( Usuario u )
    {
        usuario = u;
    }
    
    /**
     * 
     */
    private void preencherCampos()
    {
        tfUsuario.setText( usuario.getLogin() );
        tfSenha.setText( usuario.getSenha() );
    }
    
    @Override
    public void accept()
    {
        usuario.setLogin( tfUsuario.getText() );
        usuario.setSenha( tfSenha.getText() );
    }

    @Override
    public String validateInput()
    {
        return "";
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        tfSenha = new javax.swing.JTextField();
        tfUsuario = new javax.swing.JTextField();

        setLayout(new java.awt.GridBagLayout());

        jLabel2.setText("Usuario:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(15, 15, 5, 5);
        add(jLabel2, gridBagConstraints);

        jLabel3.setText("Senha:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 15, 15, 5);
        add(jLabel3, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 15, 15);
        add(tfSenha, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(15, 0, 5, 15);
        add(tfUsuario, gridBagConstraints);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JTextField tfSenha;
    private javax.swing.JTextField tfUsuario;
    // End of variables declaration//GEN-END:variables

}
